using MVP.DataAccess.Mappers;
using MVP.Domain;
using MVP.DTO;
using MVP.Task.Converters;

namespace MVP.Task
{
    public class CustomerTask : ICustomerTask
    {
        private readonly ICustomerMapper customerMapper;

        public CustomerTask() : this(new CustomerMapper())
        {
        }

        public CustomerTask(ICustomerMapper customerMapper)
        {
            this.customerMapper = customerMapper;
        }

        public ILookupCollection GetCustomerList()
        {
            return
                new LookupCollection(new CustomerToLookupConverter().ConvertAllFrom(customerMapper.GetAllCustomers()));
        }

        public CustomerDTO GetDetailsForCustomer(int customerId)
        {
            ICustomer customer = customerMapper.FindById(customerId);
            return
                new CustomerDTO(customer.Mnemonic, customer.CompanyName, customer.ContactName, customer.ContactTitle,
                                customer.Address, customer.City, customer.Region, customer.PostalCode, customer.Country,
                                customer.Phone, customer.Fax);
        }
    }
}